package org.sxf.app.sign.data;



import org.sxf.app.sign.constants.Constants;
import org.sxf.app.sign.model.CorpInfoBean;
import org.sxf.app.sign.model.SignHistoryBean;
import org.sxf.app.sign.utils.ConfigFileUtilsSingleton;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zqc on 16/6/17.
 */
public class DataCacheSingleton {
    private static DataCacheSingleton ourInstance = new DataCacheSingleton();

    public static DataCacheSingleton getInstance() {
        return ourInstance;
    }

    private DataCacheSingleton() {
    }


    private String appUrl = "";
    private String releaseNote = "";
//    private boolean isStartFromFirstPage = false;

    private String iceServerConfig = "";
    private List<CorpInfoBean> schoolBeanList;

    private String schoolCode = "";
    private String studentNo = "";
    private String pwMd5 = "";

    private String tk = "";

    private ArrayList<SignHistoryBean> mSignHistoryList;

    public void clearAllData(){
        pwMd5 = "";


        tk = "";
        ConfigFileUtilsSingleton.getInstance().clearConfig(Constants.CONFIG_KEY_TOKEN);


        mSignHistoryList = null;
    }


    public String getAppUrl() {
        return appUrl;
    }

    public void setAppUrl(String appUrl) {
        this.appUrl = appUrl;
    }

    public String getReleaseNote() {
        return releaseNote;
    }

    public void setReleaseNote(String releaseNote) {
        this.releaseNote = releaseNote;
    }

//    public boolean isStartFromFirstPage() {
//        return isStartFromFirstPage;
//    }
//
//    public void setIsStartFromFirstPage(boolean isStartFromFirstPage) {
//        this.isStartFromFirstPage = isStartFromFirstPage;
//    }


    public String getIceServerConfig() {
        return iceServerConfig;
    }

    public void setIceServerConfig(String iceServerConfig) {
        this.iceServerConfig = iceServerConfig;
    }

    public List<CorpInfoBean> getSchoolBeanList() {
        return schoolBeanList;
    }

    public void setSchoolBeanList(List<CorpInfoBean> schoolBeanList) {
        this.schoolBeanList = schoolBeanList;
    }

    public String getSchoolCode() {
        return schoolCode;
    }

    public void setSchoolCode(String schoolCode) {
        this.schoolCode = schoolCode;
    }

    public String getStudentNo() {
        return studentNo;
    }

    public void setStudentNo(String studentNo) {
        this.studentNo = studentNo;
    }

    public String getPwMd5() {
        return pwMd5;
    }

    public void setPwMd5(String pwMd5) {
        this.pwMd5 = pwMd5;
    }

    public String getTk() {
        return tk;
    }

    public void setTk(String tk) {
        this.tk = tk;
    }


    public void addSignToHistory(SignHistoryBean bean){
        if (mSignHistoryList == null){
            mSignHistoryList = new ArrayList<>();
        }

        mSignHistoryList.add(0, bean);
    }

    public ArrayList<SignHistoryBean> getSignHistory(){
        if (mSignHistoryList == null){
            mSignHistoryList = new ArrayList<>();
        }
        return mSignHistoryList;
    }
}
